<template>
    <div class="mainV">
        <div class="mainT">欢迎来到智慧医疗会诊系统</div>
        <img class="mainBg" src="@/assets/mb.png" alt="">
        <div class="mainVi">
            <el-select v-model="orgId" placeholder="请选择机构" filterable clearable>
                <el-option v-for="(i, o) in hospList" :key="o" :value="i.id" :label="i.name"></el-option>
            </el-select>
        </div>
        <div class="mainVi">
            <el-date-picker v-model="date" type="date" :disabled-date="disabledDate" placeholder="选择日期"
                :picker-options="{ disabledDate }">
            </el-date-picker>
        </div>
        <div class="mainVi">
            <el-button type="success" @click="search" style="width: 220px;margin-top: 40px;">查询</el-button>
        </div>
        <div class="tabs">
            <div class="tab tabA">
                <i class="el-icon-s-finance"></i>
                <p>问诊预约</p>
            </div>
            <div class="tab" @click="openResevation">
                <i class="el-icon-s-order"></i>
                <p>我的预约</p>
            </div>
        </div>
    </div>
</template>

<script>
import { fetchPost, fetchGet } from '@/api/request'
import moment from 'moment'
export default {
    data() {
        return {
            moment,
            hospList: [],
            orgId: null,
            date: null,
        }
    },
    mounted() {
        fetchGet('/wz/hosp/wzHospital/list', { pageNo: 1, pageSize: 999 }).then(res => {
            this.hospList = res.result.records;
        })
    },
    methods: {
        disabledDate(time) {
            return time.getTime() < Date.now() - 8.64e7;
        },
        search() {
            if (!this.orgId || !this.date) {
                this.$message.error('请填写完整信息')
                return
            }
            this.$router.push({
                path: '/search1', query: {
                    date: this.moment(this.date).format('YYYY-MM-DD'),
                    orgId: this.orgId,
                    orgName: this.hospList.find(i => i.id == this.orgId).name,
                }
            })
        },
        openResevation() {
            this.$router.push('/reservation')
        },
    },
}
</script>
<style lang="scss" scoped>
.mainV {
    width: 100vw;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    

    .mainVi {
        width: 100%;
        display: flex;
        justify-content: center;
        margin: 10px 0;
        position: relative;
        z-index: 2;
    }

    .tabs {
        position: fixed;
        left: 0;
        bottom: 0;
        width: 100vw;
        z-index: 2;
        height: 60px;
        display: flex;
        align-items: center;
        justify-content: space-around;
        box-shadow: 0 0 8px #ccc;
        background-color: #fff;

        .tab {
            width: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-direction: column;
            color: #888;

            i {
                font-size: 22px;
                margin-bottom: 5px;
            }

            p {
                font-size: 14px;
            }
        }

        .tabA {
            color: #67C23A;
            border-right: 1px solid #ccc;
        }
    }
}

.mainT {
    width: 80%;
    color: #038069;
    font-size: 33px;
    margin-bottom: 50px;
    font-weight: bold;
    text-align: center;
}

.mainBg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    opacity: .2;
    z-index: 1;
}
</style>